<template>
  <div class="per-book">
    <div class="pre-book-item" @click="toBookDetail">
      <img class="pre-book-img" :src="preBook.image" alt="书的image" />
      <div class="pre-book-info">
        <span class="title">{{ preBook.title }}</span>
        <span class="author">{{ preBook.author }}</span>
        <div class="like-evaluate" v-if="!hideLike">
          {{ preBook.fav_nums }}喜欢
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    props: ['preBook', 'hideLike'],
    methods: {
      toBookDetail() {
        wx.navigateTo({
          url: `/pages/book-detail/main?bookId=${this.preBook.id}`
        });
      }
    },
  }
</script>

<style scoped>
.per-book {
  width: 50%;
  display: flex;
  justify-content: center;
}
.pre-book-item {
  box-shadow: 2px 2px 3px #e3e3e3;
  margin-top: 30rpx;
  width: 240rpx;
  height: 360rpx;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.pre-book-img {
  width: 100%;
  flex: 1;
  border-radius: 2px;
}
.pre-book-info {
  background-color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100rpx;
  font-size: 20rpx;
  padding: 0 10rpx;
  border-bottom-left-radius: 2px;
  border-bottom-right-radius: 2px;
}
.title,
.author {
  display: inline-block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.author,
.like-evaluate {
  color: #bbb;
}
.like-evaluate {
  text-align: right;
}
</style>